package com.ssy.lingxi.report.config;

import com.querydsl.jpa.impl.JPAQueryFactory;
import com.ssy.lingxi.report.api.constant.ReportConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.persistence.EntityManager;

/**
 * 报表服务配置类
 */
@Configuration
public class ReportServiceConfig {

    @Bean
    public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
        return new JPAQueryFactory(entityManager);}

    /*********************************** 报表-新增系统操作通知 *****************************************/

    @Bean
    Queue report_sys_operate_notice_queue() {
        return new Queue(ReportConstants.REPORT_SYS_OPERATE_NOTICE_QUEUE, true, false, false);
    }

    @Bean
    DirectExchange report_sys_operate_notice_exchange() {
        return new DirectExchange(ReportConstants.REPORT_SYS_OPERATE_NOTICE_EXCHANGE, true, false);
    }

    @Bean
    Binding report_sys_operate_notice_binding() {
        return BindingBuilder.bind(report_sys_operate_notice_queue()).to(report_sys_operate_notice_exchange()).with(ReportConstants.REPORT_SYS_OPERATE_NOTICE_ROUTINGKEY);
    }

}
